<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>手机官网</title>
        <link href="css/index.css" type="text/css" rel="stylesheet">
    </head>
    <body>
		<?php 
			require("/include/menu.php");
			include("../public/config.php");
		?>
		<div class="menu container">
			<div class="menu_left">
				
					<?php
						$link = @mysqli_connect(HOST,USER,PASS,DBNAME) or die("数据库连接失败！");
						mysqli_set_charset($link,"utf8");

						// $list = array();
						$sql = "select * from type where pid = 0";
						$result = mysqli_query($link,$sql);
						$row = mysqli_fetch_assoc($result);
						
						echo '<ul>';
						echo '<li>';
						echo '<div>';
						echo '<h3><a href="list.php?tid='.$row['id'].'"">'.$row['name'].'</a></h3>';
						echo '</div>';
						$sql = "select * from type where pid = {$row['id']}";
						$result = mysqli_query($link,$sql);
						echo '<div class="div1">';
						echo '<ul style="border: none;">';
						while($listRow = mysqli_fetch_assoc($result)){
							echo '<li><a href="list.php?tid='.$listRow['id'].'">'.$listRow['name'].'</a></li>';
						}
						echo '</ul>';
						echo '</div>';
						echo '</li>';
					?>
					<li>
						<div>
							<h3><a href="#">笔记本&平板</a></h3>
						</div>
						<!--隐藏的菜单栏-->
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">笔记本&平板</a></li>
								<li><a href="#">平板电脑</a></li>
								<li><a href="#">扩展坞</a></li>
								<li><a href="#">触控笔</a></li>
								<li><a href="#">二合一键盘</a></li>
							</ul>
						</div>
					</li>
					<li>
						<div>
							<h3><a href="#">穿戴</a></h3>
						</div>
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">手表</a></li>
								<li><a href="#">手环</a></li>
							</ul>
						</div>
					</li>
					<li>
						<div>
							<h3><a href="#">智能家居</a></h3>
						</div>
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">子母路由</a></li>
								<li><a href="#">电视盒子</a></li>
								<li><a href="#">路由器</a></li>
								<li><a href="#">电力猫</a></li>
								<li><a href="#">随行wifi</a></li>
								<li><a href="#">HiLink生态产品</a></li>
							</ul>
						</div>
					</li>
					<li>
						<div>
							<h3><a href="#">专属配件</a></h3>
						</div>
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">保护壳</a></li>
								<li><a href="#">保护套</a></li>
								<li><a href="#">贴膜</a></li>
								<li><a href="#">盒子专属配件</a></li>
								<li><a href="#">表带</a></li>
								<li><a href="#">电容笔</a></li>
							</ul>
						</div>
					</li>
					<li>
						<div>
							<h3><a href="#">通用配件</a></h3>
						</div>
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">耳机</a></li>
								<li><a href="#">畅玩</a></li>
								<li><a href="#">音箱</a></li>
								<li><a href="#">移动电源</a></li>
								<li><a href="#">自拍杆/支架</a></li>
							</ul>
						</div>
					</li>
					<li>
						<div>
							<h3><a href="#">应用市场</a></h3>
						</div>
						<div class="div1">
							<ul style="border: none;">
								<li><a href="#">手机游戏</a></li>
								<li><a href="#">手机应用</a></li>
							</ul>
						</div>
					</li>
				</ul>
			</div>
			<!--菜单栏结束-->
			<!--菜单栏右边的图片-->
			<!--轮播图开始-->
			<?php
				
				//======焦点轮播图===============================================
				$sql = "select * from goods where goods like '%轮播%'";	//获取轮播图照片id
				$result = mysqli_query($link,$sql);				//发送并执行sql语句
				$row= mysqli_fetch_assoc($result);				//取出结果集
				
				//输出轮播图
				echo '<div id="menu_right">
						<a href="#"><img src="../public/uploads/'.$row['picname'].'"></a>
						<ul></ul>
					  </div>';
				
				//<!--清浮动-->
				echo '<div class="clear"></div>';
				
				$news = "select * from news";
				$newslist = mysqli_query($link,$news);
				
				
				echo '<div class="recommend_left" style="float:left;width:238px;">';
				echo '<div>';
				echo '<h2 style="margin:32px 0 12px 0;font-weight:normal;">新闻中心<h2>';
				echo '</div>';
				echo '<div style ="width:242px;height:282px;border:1px solid #ddd">';
				echo '<ul>';
				while ($newsres = mysqli_fetch_assoc($newslist)) {
					echo '<li style="overflow:hidden;text-overflow:ellipsis;margin:4px;0px;">';
					echo '<a href="news.php?id='.$newsres['id'].'"style="font-size:14px;"><nobr>'.$newsres['name'].'</nobr></a>';
					echo '</li>';
				}

				echo '</ul>';
				echo '</div>';
				echo '</div>';
				echo '<div class="recommend_right" style="float:right;">';

				//<!--热销推荐-->
				$sql = "select * from goods where typeid in(select id from type where path like '%,1,%') order by addtime desc";
				$result = mysqli_query($link,$sql);
				echo '<div class="recommend"><h2>热销推荐</h2><ul>';
					for($i=0;$i<4;$i++){
						$row = mysqli_fetch_assoc($result);
						echo '<li>
								<a href="details.php?goods='.$row[goods].'"><img src="../public/uploads/'.$row[picname].'">
									<p>'.$row[goods].'</p>
									<p>'.$row[descr].'</p>
									<p>'.$row[price].'</p>
								</a>
							  </li>';
					}
				echo '</u></div>';
				echo '</div>';
				//<!--热销产品图片栏    结束-->
			echo '</div>';
			
			echo '<!--清浮动--><div class="clear"></div>';
			
			//<!--精品手机等栏目开始-->
			
			$sql = "select * from goods where typeid in(select id from type where path like '%,1,%') order by rand()";
			
			$PhoneText = array("精品手机","笔记本&平板","智能穿戴","智能家居","热销配件","品牌配件");
			$sum = count($PhoneText);
			$FinePhone = array(array("荣耀","畅玩","华为 Mate/P系列","华为 nova系列","华为 G系列","华为 畅享系列","合约机"),
							   array("平板电脑","MateBook","扩展坞","触控笔","二合一键盘",),
							   array("手环","手表"),
							   array("子母路由","电视盒子","路由器","电力猫","随行wifi"),
							   array("保护壳","保护套","贴膜","盒子专属配件","表带","电容笔"),
							   array("音箱","移动电源","充电器/线材","U盘/存储卡","耳机","自拍杆/支架","排插","摄像机/镜头")
							   );
			// echo count($FunePhone[1][1]);
			for($j=0;$j<$sum;$j++){
				$result = mysqli_query($link,$sql);
				echo '<div class="phone">
					<div class="container phone_x">
						<div class="phone_top">
							<h2>'.$PhoneText[$j].'</h2>
						</div>';
				echo '<div class="phone_list"><ul>';
						for($i=0;$i<count($FinePhone[$j]);$i++){
							echo '<li><a href="#">'.$FinePhone[$j][$i].'</a></li>';
						}
				echo '</ul></div>';
				echo '<div class="phone_right">更多>></div>';
				echo '<div class="clear"></div>';
				
				echo '<div class="phone_pic">
						<div class="phone_pic_left">
							<img src="./img/16.jpg">
						</div>';
				
				echo '<div class="phone_pic_right"><ul>';
				
				for($i=0;$i<8;$i++){
					$row = mysqli_fetch_assoc($result);
					echo '<li>
						<a href="details.php?goods='.$row[goods].'">
							<img src="../public/uploads/'.$row[picname].'">
							<p class="p1">'.$row[goods].'</p>
							<p class="p2">'.$row[descr].'</p>
							<p class="p3">'.$row[price].'</p>
						</a>
					  </li>';
				}
				
				echo '</ul></div>
					</div>';
			}
			//<!--精品手机等栏目   结束-->
			
			echo '<div class="clear"></div>';
			//<!--广告-->
			echo '<div class="ad ad-x">
					<img src="./img/18.jpg" >
					</div>';
					
			?>	
				<?php include("./include/webbottom.php")?>
			</div>
		</div>
    </body>
</html>